package day_05;

import java.util.Scanner;

/**
 * @ClassName Day05Homework_15
 * @Description TODO
 * @Author hp
 * @Date 2021/6/7 19:26
 * @Version 1.0
 **/
public class Day05Homework_15 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("一共有几组:");
        int group = scanner.nextInt();
        int[][] tables = new int[group][];
        int count= 0;

        double sum = 0.0;

        for (int i = 0; i <group ; i++) {
            System.out.println("请输入第"+(i+1)+"组的人数:");
            int num = scanner.nextInt();
            tables[i]=new int[num];
        }
        for (int i = 0; i <tables.length ; i++) {
            for (int j = 0; j <tables[i].length ; j++) {
                System.out.println("请输入第"+(i+1)+"组的人的成绩:");
                tables[i][j]=scanner.nextInt();
                count++;
            }
        }
        /*------------------------------------------------------------------------------*/
        int max = tables[0][0];
        int min = tables[0][0];
        double[][] doubles = new double[3][group];
        for (int i = 0; i <tables.length ; i++) {
            doubles[0][i]=tables[i][0];
            doubles[1][i]=tables[i][0];
            for (int j = 0; j <tables[i].length ; j++) {
                if (max<tables[i][j]){
                    max = tables[i][j];
                }
                if (min>tables[i][j]){
                    min = tables[i][j];
                }
                sum +=tables[i][j];
                if (doubles[0][i]>tables[i][j]){
                    doubles[0][i]=tables[i][j];         //获得最小值
                }
                if (doubles[1][i]<tables[i][j]){
                    doubles[1][i]=tables[i][j];         //获得最大值
                }
                doubles[2][i]+=tables[i][j];
            }
            doubles[2][i] = doubles[2][i]/tables[i].length;
        }
        /*------------------------------------------------------------------------------*/
        for (int i = 0; i <doubles.length ; i++) {
            for (int j = 0; j <doubles[i].length ; j++) {
                if (i == 0){
                    System.out.println("第"+(j+1)+"的最低分:"+doubles[i][j]);
                }else if(i == 1){
                    System.out.println("第"+(j+1)+"的最高分:"+doubles[i][j]);
                }else {
                    System.out.println("第"+(j+1)+"的平均分:"+doubles[i][j]);
                }
            }
        }
        System.out.println("全班最高分为:"+max);
        System.out.println("全班最低分为:"+min);
        System.out.println("全班平均分为:"+sum/count);
        System.out.println("全班总人数为:"+count);


    }

}
